﻿using Windows.Data.Json;

namespace XiaoweiV2.ResponseDataTypes
{
    public class MediaExtraInfo: IDataType
    {
        #region Properties that parsed from json
        private const string AlbumKey = "album";
        private const string ArtistKey = "artist";
        private const string CoverKey = "cover";
        private const string DurationKey = "duration";
        private const string FavoriteKey = "favorite";
        private const string NameKey = "name";
        private const string PlayIdKey = "playId";
        private const string PlayableKey = "playable";
        private const string QualityKey = "quality";
        private const string SkillIdKey = "skillId";
        private const string SkillNameKey = "skillName";
        private const string UnplayableCodeKey = "unplayableCode";
        private const string UnplayableMsgKey = "unplayableMsg";
        private const string SummaryMsgKey = "summary";

        public string Album { get; set; }
        public string Artist { get; set; }
        public string Cover { get; set; }
        public double Duration { get; set; }
        public bool Favorite { get; set; }
        public string Name { get; set; }
        public string PlayId { get; set; }
        public bool Playable { get; set; }
        public double Quality { get; set; }
        public string SkillId { get; set; }
        public string SkillName { get; set; }
        public double UnplayableCode { get; set; }
        public string UnplayableMsg { get; set; }
        #endregion

        public string Id { get; set; }
        public string Url { get; set; }
        public int PlayCount { get; set; }
        public ulong Offset { get; set; }
        public string Summary { get; set; }

        public void FromJson(JsonObject json)
        {
            if (json == null) return;
            this.Album = json.GetNamedString(AlbumKey, "");
            this.Artist = json.GetNamedString(ArtistKey, "");
            this.Cover = json.GetNamedString(CoverKey, "");
            this.Duration = json.GetNamedNumber(DurationKey, 0d);
            this.Favorite = json.GetNamedBoolean(FavoriteKey, false);
            this.Name = json.GetNamedString(NameKey, "");
            this.PlayId = json.GetNamedString(PlayIdKey, "");
            this.Playable = json.GetNamedBoolean(PlayableKey, false);
            this.Quality = json.GetNamedNumber(QualityKey, 0d);
            this.SkillId = json.GetNamedString(SkillIdKey, "");
            this.SkillName = json.GetNamedString(SkillNameKey, "");
            this.UnplayableCode = json.GetNamedNumber(UnplayableCodeKey, 0.0);
            this.UnplayableMsg = json.GetNamedString(UnplayableMsgKey, "");
            this.Summary = json.GetNamedString(SummaryMsgKey, "");
        }

        public JsonObject ToJson()
        {
            return null;
        }
    }
}
